﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Howork
{
    public class DeviceInfo
    {
        public int id;
        public string device_name;
        public int type_id;
        public String type_name;
        public bool used;

        public int state;
        public string from;
        public string to;
        public String user_id;
        public String user_name;

    }
    public class DeviceManage
    {
        private DBAdapter db;
        public DeviceManage()
        {
            db = new DBAdapter();
        }
        public List<DeviceInfo> GetFreeDeviceList(int type_id, DateTime from, DateTime to)
        {
            return db.getFreeDevice(type_id, from, to);
        }
        public bool ArrangeDevice(int device_id,DateTime from,DateTime to ,string user_id) 
        {
            db.addDevice_use(device_id, from, to, user_id);
            return true;
        }
        public List<DeviceTypeInfo> GetDeviceType()
        {
            return db.getDeviceTypeList();
        }
        public bool CheckEmploee(string user_id)
        {
            return db.checkEmployee(user_id);
        }
        public List<DeviceInfo> GetDeviceList()
        {
            return db.getDeviceList();
        }
        public bool DeleteDevice(int id)
        {
            return db.deleteDevice(id);
        }
        public bool AddDevice(string name, int typeId)
        {
            return db.addDevice(name, typeId);
        }
        public int AddType(string name)
        {
            return db.addDeviceType(name);
        }
        public List<DeviceUsage> GetDeviceUsageHistory(DateTime from, DateTime to, int device_type)
        {
            return db.getDeviceUsageHistory(from, to, device_type);
        }
    }
    public class DeviceTypeInfo
    {
        public int id;
        public String name;
    }

    public class DeviceUsage
    {
        public int id;
        public String device_name;
        public String  timeFrom;
        public String timeTo;
        public String userID;
        public String typeName;
    }
}